/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SStoreConverter.java
 * Created：		2016年7月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.user.converter;

import java.util.ArrayList;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.user.AContracts;
import com.thor.palmmall.spi.user.SContracts;

/**
 * @author captain
 *
 */
public class AContractsConverter implements Converter<SContracts, AContracts> {

  public static AContractsConverter getInstance() {
    if (instance == null)
      instance = new AContractsConverter();
    return instance;
  }

  private static AContractsConverter instance;

  private AContractsConverter() {
  }

  @Override
  public AContracts convert(SContracts source) {
    if (source == null)
      return null;

    AContracts target = new AContracts();
    target.setCode(source.getCode());
    target.setName(source.getName());
    target.setUuid(source.getUuid());
    target.setState(source.getState());
    target.setContractType(source.getContractType());
    target.setPositions(new ArrayList<UCN>());
    target.getPositions().addAll(source.getPositions());
    return target;
  }

}
